package com.yujistu.activity;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.yujistu.R;

/**
 * Created by S3YOGA on 2015/11/3.
 */
public class ProtocolWebActivity extends BaseActivity {

    ProgressBar  progressBar;
    WebView     webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_us);

        ((TextView)findViewById(R.id.tv_title_title)).setText("用户协议");
        findViewById(R.id.backIv).setOnClickListener(mOnClickListener);

       progressBar = (ProgressBar)findViewById(R.id.progressbar);
       progressBar.setProgress(100);
       webView = (WebView)findViewById(R.id.about_us_wv);
        webView.setWebChromeClient(new MyWebClient());
        webView.loadUrl("http://weixin.binduyoga.cn/index.php?route=weixin/agreement/privacy");
    }

    ImageView  leftIV;

    View.OnClickListener mOnClickListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()){
                case R.id.backIv:
                    leftIV.setVisibility(View.VISIBLE);
                    finish();
                    break;
            }
        }
    };

    public class MyWebClient extends WebChromeClient{
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            ProtocolWebActivity.this.setValue(newProgress);
            super.onProgressChanged(view, newProgress);
        }
    }

    public void setValue(int num){
        this.progressBar.setProgress(num);
        if(num >= 100){
            progressBar.setVisibility(View.GONE);
        }
    }
}
